From: Keir Fraser Date: Mon, 12 Apr 2010 17:28:33 +0000 (+0100) Subject: xentrace: fix lost records resume X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12390 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=741bcc86e29e8d46285d46a63225186c74d34bc3;p=xen.git xentrace: fix lost records resume Reorder the SCHED_SWITCH trace before the runstate change trace to fix a problem with the lost records "resume" code. Namely: The "lost records" trace includes the currently running process. But during SCHED_SWITCH, it reads the wrong value, confusing xenalyze. Making sure there are no trace records between runstate change trace and the actual context switch fixes it. Signed-off-by: George Dunlap --- diff --git a/xen/common/schedule.c b/xen/common/schedule.c index fdb9e8d0d2..70289041d2 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -877,6 +877,11 @@ static void schedule(void) next_slice.time); ASSERT(prev->runstate.state == RUNSTATE_running); + + TRACE_4D(TRC_SCHED_SWITCH, + prev->domain->domain_id, prev->vcpu_id, + next->domain->domain_id, next->vcpu_id); + vcpu_runstate_change( prev, (test_bit(_VPF_blocked, &prev->pause_flags) ? RUNSTATE_blocked : @@ -887,6 +892,11 @@ static void schedule(void) ASSERT(next->runstate.state != RUNSTATE_running); vcpu_runstate_change(next, RUNSTATE_running, now); + /* + * NB. Don't add any trace records from here until the actual context + * switch, else lost_records resume will not work properly. + */ + ASSERT(!next->is_running); next->is_running = 1; @@ -900,10 +910,6 @@ static void schedule(void) update_vcpu_system_time(next); vcpu_periodic_timer_work(next); - TRACE_4D(TRC_SCHED_SWITCH, - prev->domain->domain_id, prev->vcpu_id, - next->domain->domain_id, next->vcpu_id); - context_switch(prev, next); }